<template>
  <el-container>
    <el-header class="margin-bottom20 padding0">
      <router-link
        :to="{ name: '比赛题目' }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >比赛题目</el-button
        >
      </router-link>
      <router-link
        :to="{ name: '报名用户', params: { ID } }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >查看报名</el-button
        >
      </router-link>
      <router-link
        :to="{ name: '比赛成绩', params: { ID } }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >查看成绩</el-button
        >
      </router-link>
      <router-link
        :to="{ name: '比赛短信发送', params: { ID } }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >比赛短信发送</el-button
        >
      </router-link>
      <router-link
        :to="{ name: '比赛其他功能', params: { ID } }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >比赛其他功能</el-button
        >
      </router-link>
      <router-link
        v-if="!tenant_id"
        :to="{ name: 'AI分析比赛', params: { ID } }"
        custom
        v-slot="{ navigate, isActive }"
      >
        <el-button @click="navigate" :type="!isActive ? 'default' : 'primary'"
          >AI分析</el-button
        >
      </router-link>
    </el-header>
    <router-view v-if="activity" :data="activity"></router-view>
  </el-container>
</template>
<script setup lang="ts">
import { inject, onMounted, ref } from "vue";
import { asyncadmingetactivity } from "../../../api";
import Studycodemodel from "../../../mysql_interface/studycodemodel";

// 码客行
const tenant_id = inject<string | undefined>("tenant_id", undefined);

const p = defineProps<{ ID: number }>();

const activity = ref<Studycodemodel.Iactivity>();

async function start() {
  if (p.ID) {
    const data = await asyncadmingetactivity({ ID: p.ID });
    activity.value = data;
  }
}

onMounted(() => {
  start();
});
</script>
